home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / edit / tde40.zip / cfgmodes.c < prev    next >
C/C++ Source or Header  |  1994-06-05  |  14KB  |  584 lines

  1. /*
  2.  * Author:        Frank Davis
  3.  * Date:          January 20, 1992
  4.  * Compiler:      MSC 6.0a and QuickC 2.5
  5.  *
  6.  * This program is released into the public domain.  You may distribute
  7.  * it freely, Frank Davis
  8.  */
  9.  
  10.  
  11. #include <bios.h>
  12. #include <dos.h>
  13. #include <stdlib.h>
  14. #include <stdio.h>
  15. #include <string.h>
  16.  
  17. #include "tdecfg.h"
  18. #include "cfgmodes.h"
  19.  
  20.  
  21. extern struct vcfg cfg;         /* video stuff */
  22. extern FILE *tde_exe;           /* FILE pointer to tde.exe */
  23. extern long mode_offset;
  24.  
  25. MODE_INFO in_modes;           /* play around with modes in this struct */
  26.  
  27. int color;
  28.  
  29. /*
  30.  * Name:    tdemodes
  31.  * Date:    July 21, 1991
  32.  * Notes:   Strategy is fairly straight forward -  1) initialize all the
  33.  *          variables  2) show the user a color sample  3) make the changes
  34.  *          permanent if desired.
  35.  */
  36. void tdemodes( void )
  37. {
  38.    color = 7;
  39.    initialize_modes( );
  40.    show_init_mode( );
  41.    change_modes( );
  42. }
  43.  
  44.  
  45. /*
  46.  * Name:    initialize_modes
  47.  * Date:    July 21, 1991
  48.  * Notes:   Set up the global mode variables.
  49.  */
  50. void initialize_modes( void )
  51. {
  52. int i, j;
  53.  
  54.    fseek( tde_exe, mode_offset, SEEK_SET );
  55.    fread( (void *)&in_modes, sizeof( MODE_INFO ), 1, tde_exe );
  56.  
  57.    mode[Ins].mode      = in_modes.insert;
  58.    mode[Ind].mode      = in_modes.indent;
  59.    mode[PTAB].mode     = in_modes.ptab_size;
  60.    mode[LTAB].mode     = in_modes.ltab_size;
  61.    mode[Smart].mode    = in_modes.smart_tab;
  62.    mode[Write_Z].mode  = in_modes.control_z;
  63.    mode[Crlf].mode     = in_modes.crlf;
  64.    mode[Trim].mode     = in_modes.trailing;
  65.    mode[Eol].mode      = in_modes.show_eol;
  66.    mode[WW].mode       = in_modes.word_wrap;
  67.    mode[Left].mode     = in_modes.left_margin;
  68.    mode[Para].mode     = in_modes.parg_margin;
  69.    mode[Right].mode    = in_modes.right_margin;
  70.    mode[Size].mode     = in_modes.cursor_size;
  71.    mode[Backup].mode   = in_modes.do_backups;
  72.    mode[Ruler].mode    = in_modes.ruler;
  73.    mode[Date].mode     = in_modes.date_style;
  74.    mode[Time].mode     = in_modes.time_style;
  75.    mode[Initcase].mode = in_modes.search_case;
  76. }
  77.  
  78.  
  79. /*
  80.  * Name:    show_init_mode
  81.  * Date:    July 21, 1991
  82.  * Notes:   Draw the sample screen.
  83.  */
  84. void show_init_mode( void )
  85. {
  86. char *sample;
  87. int line, i;
  88.  
  89.    cls( );
  90.    xygoto( -1, -1 );
  91.    sample = mode_screen[0];
  92.    for (i=0,line=1; sample != NULL; line++, i++) {
  93.       sample = mode_screen[i];
  94.       s_output( (char far *)sample, line, 0, 7 );
  95.    }
  96.    for (i=0; i<19; i++)
  97.       (*mode[i].show_me)();
  98. }
  99.  
  100.  
  101. /*
  102.  * Name:    show_insert_mode
  103.  * Date:    January 20, 1992
  104.  */
  105. void show_insert_mode( void )
  106. {
  107. char *p[] = {
  108.    "Overwrite",
  109.    "Insert   "
  110. };
  111.  
  112.    s_output( p[mode[Ins].mode], mode[Ins].line, mode[Ins].col, color );
  113. }
  114.  
  115.  
  116. /*
  117.  * Name:    show_indent_mode
  118.  * Date:    January 20, 1992
  119.  */
  120. void show_indent_mode( void )
  121. {
  122. char *p[] = {
  123.    "Indent off",
  124.    "Indent on "
  125. };
  126.  
  127.    s_output( p[mode[Ind].mode], mode[Ind].line, mode[Ind].col, color );
  128. }
  129.  
  130.  
  131. /*
  132.  * Name:    show_ptabsize
  133.  * Date:    January 20, 1992
  134.  */
  135. void show_ptabsize( void )
  136. {
  137. char temp[10];
  138.  
  139.    s_output( "   ", mode[PTAB].line, mode[PTAB].col, color );
  140.    s_output( itoa(mode[PTAB].mode,temp,10), mode[PTAB].line, mode[PTAB].col,color);
  141. }
  142.  
  143.  
  144. /*
  145.  * Name:    show_ltabsize
  146.  * Date:    January 20, 1992
  147.  */
  148. void show_ltabsize( void )
  149. {
  150. char temp[10];
  151.  
  152.    s_output( "   ", mode[LTAB].line, mode[LTAB].col, color );
  153.    s_output( itoa(mode[LTAB].mode,temp,10), mode[LTAB].line, mode[LTAB].col,color);
  154. }
  155.  
  156.  
  157. /*
  158.  * Name:    show_controlz
  159.  * Date:    January 20, 1992
  160.  */
  161. void show_controlz( void )
  162. {
  163. char *p[] = {
  164.    "No ^Z   ",
  165.    "Write ^Z",
  166. };
  167.  
  168.    s_output( p[mode[Write_Z].mode], mode[Write_Z].line,mode[Write_Z].col,color);
  169. }
  170.  
  171.  
  172. /*
  173.  * Name:    show_eol_out
  174.  * Date:    January 20, 1992
  175.  */
  176. void show_eol_out( void )
  177. {
  178. char *p[] = {
  179.    "",
  180.    "CRLF",
  181.    "LF  ",
  182. };
  183.  
  184.    s_output( p[mode[Crlf].mode], mode[Crlf].line, mode[Crlf].col, color );
  185. }
  186.  
  187.  
  188. /*
  189.  * Name:    show_trail
  190.  * Date:    January 20, 1992
  191.  */
  192. void show_trail( void )
  193. {
  194. char *p[] = {
  195.    "No Trim",
  196.    "Trim   ",
  197. };
  198.  
  199.    s_output( p[mode[Trim].mode], mode[Trim].line, mode[Trim].col, color );
  200. }
  201.  
  202.  
  203. /*
  204.  * Name:    show_eol_display
  205.  * Date:    January 20, 1992
  206.  */
  207. void show_eol_display( void )
  208. {
  209. char *p[] = {
  210.    "Off",
  211.    "On ",
  212. };
  213.  
  214.    s_output( p[mode[Eol].mode], mode[Eol].line, mode[Eol].col, color );
  215. }
  216.  
  217.  
  218. /*
  219.  * Name:    show_smart_mode
  220.  * Date:    January 20, 1992
  221.  */
  222. void show_smart_mode( void )
  223. {
  224. char *p[] = {
  225.    "Off",
  226.    "On ",
  227. };
  228.  
  229.    s_output( p[mode[Smart].mode], mode[Smart].line, mode[Smart].col, color );
  230. }
  231.  
  232.  
  233. /*
  234.  * Name:    show_ww
  235.  * Date:    January 20, 1992
  236.  */
  237. void show_ww( void )
  238. {
  239. char *p[] = {
  240.    "Off                ",
  241.    "Fixed margins      ",
  242.    "Dynamic left margin",
  243. };
  244.  
  245.    s_output( p[mode[WW].mode], mode[WW].line, mode[WW].col, color );
  246. }
  247.  
  248.  
  249. /*
  250.  * Name:    show_initcase
  251.  * Date:    January 20, 1992
  252.  */
  253. void show_initcase( void )
  254. {
  255. char *p[] = {
  256.    "      ",
  257.    "IGNORE",
  258.    "MATCH ",
  259. };
  260.  
  261.    s_output( p[mode[Initcase].mode], mode[Initcase].line, mode[Initcase].col,
  262.               color );
  263. }
  264.  
  265.  
  266. /*
  267.  * Name:    show_left
  268.  * Date:    January 20, 1992
  269.  */
  270. void show_left( void )
  271. {
  272. char temp[10];
  273.  
  274.    s_output( "   ", mode[Left].line, mode[Left].col, color );
  275.    s_output( itoa( mode[Left].mode+1, temp, 10 ), mode[Left].line, mode[Left].col,
  276.              color);
  277. }
  278.  
  279.  
  280. /*
  281.  * Name:    show_para
  282.  * Date:    January 20, 1992
  283.  */
  284. void show_para( void )
  285. {
  286. char temp[10];
  287.  
  288.    s_output( "   ", mode[Para].line, mode[Para].col, color );
  289.    s_output( itoa( mode[Para].mode+1, temp, 10 ), mode[Para].line, mode[Para].col,
  290.              color);
  291. }
  292.  
  293.  
  294. /*
  295.  * Name:    show_right
  296.  * Date:    January 20, 1992
  297.  */
  298. void show_right( void )
  299. {
  300. char temp[10];
  301.  
  302.    s_output( "   ", mode[Right].line, mode[Right].col, color );
  303.    s_output( itoa(mode[Right].mode+1,temp,10), mode[Right].line, mode[Right].col,
  304.              color);
  305. }
  306.  
  307.  
  308. /*
  309.  * Name:    show_cursor_size
  310.  * Date:    January 20, 1992
  311.  */
  312. void show_cursor_size( void )
  313. {
  314. char *p[] = {
  315.    "Small Insert Cursor",
  316.    "Big Insert Cursor  ",
  317. };
  318.  
  319.    s_output( p[mode[Size].mode], mode[Size].line, mode[Size].col, color );
  320. }
  321.  
  322.  
  323. /*
  324.  * Name:    show_backup_mode
  325.  * Date:    January 20, 1992
  326.  */
  327. void show_backup_mode( void )
  328. {
  329. char *p[] = {
  330.    "No .bak files    ",
  331.    "Create .bak files"
  332. };
  333.  
  334.    s_output( p[mode[Backup].mode], mode[Backup].line, mode[Backup].col, color );
  335. }
  336.  
  337.  
  338. /*
  339.  * Name:    show_backup_mode
  340.  * Date:    January 20, 1992
  341.  */
  342. void show_ruler_mode( void )
  343. {
  344. char *p[] = {
  345.    "No ruler  ",
  346.    "Show ruler"
  347. };
  348.  
  349.    s_output( p[mode[Ruler].mode], mode[Ruler].line, mode[Ruler].col, color );
  350. }
  351.  
  352.  
  353. /*
  354.  * Name:    show_date_style
  355.  * Date:    June 5, 1992
  356.  */
  357. void show_date_style( void )
  358. {
  359. char *p[] = {
  360.    "MM_DD_YY  ",
  361.    "DD_MM_YY  ",
  362.    "YY_MM_DD  ",
  363.    "MM_DD_YYYY",
  364.    "DD_MM_YYYY",
  365.    "YYYY_MM_DD",
  366. };
  367.  
  368.    s_output( p[mode[Date].mode], mode[Date].line, mode[Date].col, color );
  369. }
  370.  
  371.  
  372. /*
  373.  * Name:    show_time_style
  374.  * Date:    June 5, 1992
  375.  */
  376. void show_time_style( void )
  377. {
  378. char *p[] = {
  379.    "12_HOUR",
  380.    "24_HOUR"
  381. };
  382.  
  383.    s_output( p[mode[Time].mode], mode[Time].line, mode[Time].col, color );
  384. }
  385.  
  386.  
  387. /*
  388.  * Name:    change_modes
  389.  * Date:    July 21, 1991
  390.  * Notes:   Real workhorse function of the utility.  Get a key and then
  391.  *          figure out what to do with it.
  392.  */
  393. void change_modes( void )
  394. {
  395. int c;
  396. int m;
  397. int new_field;
  398.  
  399.    m = 0;
  400.    xygoto( mode[m].col, mode[m].line );
  401.    color = 112;
  402.    (*mode[m].show_me)();
  403.    for (c=0; c != F3  &&  c != F10  &&  c != ESC;) {
  404.       c = getkey( );
  405.       new_field = FALSE;
  406.       color = 112;
  407.       switch (c) {
  408.          case RTURN :
  409.          case DOWN  :
  410.             color = 7;
  411.             (*mode[m].show_me)();
  412.             ++m;
  413.             if (m > 18)
  414.                m = 0;
  415.             new_field = TRUE;
  416.             break;
  417.          case UP    :
  418.             color = 7;
  419.             (*mode[m].show_me)();
  420.